package com.qbt.unipock.agent.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.qbt.unipock.agent.interfaces.DistributorContract;
import com.qbt.unipock.agent.services.DistributorService;
import com.xjoyt.pay.controllers.AbstractController;
import com.xjoyt.pay.dto.ExecuteResult;
import com.xjoyt.pay.dto.PageParam;
import com.xjoyt.pay.dto.PageResult;

import com.xjoyt.pay.master.po.Distributor;
import com.xjoyt.pay.merchant.register.params.DistributorPageParam;
import com.xjoyt.pay.params.ChangePasswordParam;
import com.xjoyt.pay.params.LoginParam;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;


@RestController
@RequestMapping("distributor")
//extends AbstractController implements DistributorContract
public class DistributorController  {

	@Autowired
	private DistributorService service;

	
	@RequestMapping("get/{id}")
	public Distributor get(@PathVariable("id") String id) {
		return service.get(id);
	}

	@RequestMapping(value = "loadPage", method = RequestMethod.POST)
	public PageResult<Distributor> loadPage(@RequestBody PageParam<DistributorPageParam> param) {
		return service.loadPage(param);
	}

	/*-
	public ExecuteResult<?> changePassword(@RequestBody ChangePasswordParam param) {
		return service.changePassword(param);
	}*/
	
	
	@RequestMapping(value = "create", method = RequestMethod.POST)
	public ExecuteResult<?> create(@RequestBody Distributor param) {
		return service.create(param);
	}
	

	/**
	 * 通过商户号获取代理商
	 * 
	 * @param no
	 * @return
	 */
	public Distributor getByNo(@PathVariable("no") String no) {
		return service.getByNo(no);
	}

	/*
	public ExecuteResult<String> resetKey(@PathVariable("id") String id) {
		return service.resetKey(id);
	}*/

	/*
	public ExecuteResult<Distributor> getForLogin(@RequestBody LoginParam param) {
		return service.getForLogin(param.account, param.password);
	}*/
	/**
	 * 修改
	 * 
	 * @param param
	 * @return
	 */
	@RequestMapping(value = "update", method = RequestMethod.POST)
	public ExecuteResult<Distributor> update(@RequestBody Distributor param) {
		return service.update(param);
	}

}
